import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import replace from "@rollup/plugin-replace";
import {resolvePkgPath} from '../rollup/utils'
import path from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  server:{
    port:3030,
    host:true,
    open:true
  },
  plugins: [
    react(),
    replace({
      preventAssignment: true,
      __DEV__: true,
    }),
  ],
  resolve:{
    alias:[
      {
        find:"react",
        replacement:resolvePkgPath("react")
      },
      {
        find:"react-dom",
        replacement:resolvePkgPath("react-dom")
      },
      {
        find:"react-noop-renderer",
        replacement:resolvePkgPath("react-noop-renderer")
      },
      {
        find:"hostConfig",
        replacement:path.resolve(resolvePkgPath("react-dom"),"./src/hostConfig.ts")
        // replacement:path.resolve(resolvePkgPath("react-noop-renderer"),"./src/hostConfig.ts")
      }
    ]
  }
})
